home *** CD-ROM | disk | FTP | other *** search
- /* putpixel.c */
- /* Entered by A. Wayner */
-
- # include <graphics.h>
-
- main()
- {
- int graphdriver = DETECT;
- int graphmode, x, y, color, xstep;
-
- /* Detect adapter type and */
- /* initialize graphics system */
- initgraph( &graphdriver, &graphmode, "\\turboc");
- outtextxy( 10, 10, "Multicolored rectangle using putpixel ");
-
- /* Go over a rectangular region and */
- /* fill pixels with color */
-
- xstep = (getmaxx() - 100) / (getmaxcolor() + 1 );
- color = 0; /* initialize first color in the palette */
-
- for( x = 50; x < getmaxx() - 50; x++ )
- {
- for( y = 40; y < getmaxy() - 40; y++ )
- {
- putpixel( x, y, color ); /* Set pixel to color */
- }
- if( (x % xstep ) == 0) color++; /* got to next color */
- if( color > getmaxcolor())
- color = 0;
-
- }
-
- outtextxy( 10, getmaxy() - 30,"Press any key to exit : ");
-
- getch(); /* Wait until a key is pressed */
- closegraph(); /* Exit graphics library */
-
- }